package com.xqb.modules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xqb.modules.domain.po.InsInstitution;
import com.xqb.modules.mapper.InsInstitutionMapper;
import com.xqb.modules.service.IInsInstitutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 机构Service业务层处理
 * 
 * @author xqb
 * @date 2024-10-14
 */
@Service
public class InsInstitutionServiceImpl implements IInsInstitutionService 
{
    @Autowired
    private InsInstitutionMapper insInstitutionMapper;

    /**
     * 查询机构
     * 
     * @param id 机构主键
     * @return 机构
     */
    @Override
    public InsInstitution selectInsInstitutionById(Long id)
    {
        return insInstitutionMapper.selectInsInstitutionById(id);
    }

    /**
     * 查询机构列表
     * 
     * @param insInstitution 机构
     * @return 机构
     */
    @Override
    public List<InsInstitution> selectInsInstitutionList(InsInstitution insInstitution)
    {
        return insInstitutionMapper.selectInsInstitutionList(insInstitution);
    }

    /**
     * 新增机构
     * 
     * @param insInstitution 机构
     * @return 结果
     */
    @Override
    public int insertInsInstitution(InsInstitution insInstitution)
    {
        return insInstitutionMapper.insertInsInstitution(insInstitution);
    }

    /**
     * 修改机构
     * 
     * @param insInstitution 机构
     * @return 结果
     */
    @Override
    public int updateInsInstitution(InsInstitution insInstitution)
    {
        return insInstitutionMapper.updateInsInstitution(insInstitution);
    }

    /**
     * 批量删除机构
     * 
     * @param ids 需要删除的机构主键
     * @return 结果
     */
    @Override
    public int deleteInsInstitutionByIds(Long[] ids)
    {
        return insInstitutionMapper.deleteInsInstitutionByIds(ids);
    }

    /**
     * 删除机构信息
     * 
     * @param id 机构主键
     * @return 结果
     */
    @Override
    public int deleteInsInstitutionById(Long id)
    {
        return insInstitutionMapper.deleteInsInstitutionById(id);
    }

    @Override
    public InsInstitution selectInsInstitutionByName(String insName) {
        QueryWrapper<InsInstitution> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("full_name", insName);
        return insInstitutionMapper.selectOne(queryWrapper);
    }
}
